package top.haijunit.work.core.doamin;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 异常枚举类
 *
 * @author zhanghaijun
 * @since 2024-08-07
 */
@Getter
@AllArgsConstructor
public enum ExceptionEnum {

    // 成功状态码
    SUCCESS(2000, "操作成功!"),

    // 客户端错误状态码
    BAD_REQUEST(4000, "错误的请求!"),
    BODY_NOT_MATCH(4001, "请求的数据格式不符!"),
    PARAMS_NOT_CONVERT(4002, "类型转换不对!"),
    PARAMS_CAPTCHA_ERROR(4003, "验证码错误!"),
    UNAUTHORIZED(4010, "未授权!"),
    FORBIDDEN(4030, "禁止访问!"),
    NOT_FOUND(4040, "未找到资源!"),
    METHOD_NOT_ALLOWED(4050, "方法不允许!"),
    REQUEST_TIMEOUT(4080, "请求超时!"),
    CONFLICT(4090, "资源冲突!"),
    UNSUPPORTED_MEDIA_TYPE(4150, "不支持的媒体类型!"),
    UNPROCESSABLE_ENTITY(4220, "无法处理的实体!"),
    TOO_MANY_REQUESTS(4290, "请求过于频繁，请稍后尝试!"),

    // 服务器错误状态码
    INTERNAL_SERVER_ERROR(5000, "服务器内部错误!"),
    NOT_IMPLEMENTED(5010, "功能未实现!"),
    SERVICE_UNAVAILABLE(5030, "服务不可用!"),
    GET_LOCK_ERROR(5060, "获取分布式锁异常"),

    // 数据库错误状态码
    DATABASE_ERROR(6000, "数据库错误!"),
    DATA_NOT_FOUND(6001, "数据未找到!"),
    DATA_INTEGRITY_VIOLATION(6002, "数据完整性违反!"),

    // 自定义业务错误状态码
    VALIDATION_ERROR(7000, "参数验证失败!"),
    BUSINESS_ERROR(7001, "业务逻辑错误!"),
    OPERATION_FAILED(7002, "操作失败!"),
    ;

    private final Integer code;
    private final String message;
}
